x86 hvm domain builder, restore: set shared_info.arch.max_pfn for
authorKeir Fraser <keir@xensource.com>
Sat, 24 Feb 2007 14:19:05 +0000 (14:19 +0000)
committerKeir Fraser <keir@xensource.com>
Sat, 24 Feb 2007 14:19:05 +0000 (14:19 +0000)
dump-core to know the area to dump

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/xc_hvm_build.c
tools/libxc/xc_hvm_restore.c

index 28bc512218a2e964bdc87060dee81bec0b1d6bf2..0792c8522f0a5cc5a0c7809930446176b23f373c 100644 (file)
@@ -262,6 +262,7 @@ static int setup_guest(int xc_handle,
     /* NB. evtchn_upcall_mask is unused: leave as zero. */
     memset(&shared_info->evtchn_mask[0], 0xff,
            sizeof(shared_info->evtchn_mask));
+    shared_info->arch.max_pfn = page_array[nr_pages - 1];
     munmap(shared_info, PAGE_SIZE);
 
     if ( v_end > HVM_BELOW_4G_RAM_END )
index 3d292d82ccbc1f088b31989b39914178edfd800a..001fe2a6e4d6a64e6c97ea82c4d1ece5c32e062d 100644 (file)
@@ -86,6 +86,8 @@ int xc_hvm_restore(int xc_handle, int io_fd,
     uint8_t *hvm_buf = NULL;
     unsigned long long v_end, memsize;
     unsigned long shared_page_nr;
+    shared_info_t *shared_info = NULL;
+    xen_pfn_t arch_max_pfn;
 
     unsigned long pfn;
     unsigned int prev_pc, this_pc;
@@ -141,6 +143,7 @@ int xc_hvm_restore(int xc_handle, int io_fd,
         pfns[i] = i;
     for ( i = HVM_BELOW_4G_RAM_END >> PAGE_SHIFT; i < max_pfn; i++ )
         pfns[i] += HVM_BELOW_4G_MMIO_LENGTH >> PAGE_SHIFT;
+    arch_max_pfn = pfns[max_pfn - 1];/* used later */
 
     /* Allocate memory for HVM guest, skipping VGA hole 0xA0000-0xC0000. */
     rc = xc_domain_memory_populate_physmap(
@@ -350,6 +353,14 @@ int xc_hvm_restore(int xc_handle, int io_fd,
         ERROR("setting the shared-info pfn failed!\n");
         goto out;
     }
+    if ( (xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp) != 0) ||
+         ((shared_info = xc_map_foreign_range(
+             xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
+             shared_info_frame)) == NULL) )
+        goto out;
+    /* shared_info.arch.max_pfn is used by dump-core */
+    shared_info->arch.max_pfn = arch_max_pfn;
+    munmap(shared_info, PAGE_SIZE);
 
     rc = 0;
     goto out;